<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>商品库存管理</title>
    <link rel="stylesheet"  href="__ROOT__/static/plugins/bootstrap/css/bootstrap.css">
    <script src="__ROOT__/static/admin/js/jquery-1.11.1.min.js"></script>
    <script  src="__ROOT__/static/plugins/layer/layer.min.js"></script>
</head>

    <script>
        $(function(){
            $('#initial').change(function(){
                $("#stock").val("");
            });
        });

        function but(){
            var params = {};
            params.id = $('.id').val();
            params.res = $('#initial').val();
            params.num = $('#stock').val();
            $.post("{:url('admin/Goods/setStock')}",params,function(data){
                if(data == 1){
                    layer.msg('修改成功', {icon:1});
                    setTimeout('location.href="{:url(\'admin/Goods/index\')}"',2500);
                }else{
                    layer.msg('修改失败', {icon:1});
                }
            })
        }
    </script>
<body>
<form name="myform" method="post" action="">
    <input type="hidden" name="id" class="id"  value="{$res.id}" />
    <table class="table table-hover table-striped table-bordered wst-form">
        <tr>
            <th>商品名称</th>
            <td>
                 {$res.goods_name}
            </td>
        </tr>
        <tr>
            <th>初始库存</th>
            <td>
                {$res.initial_stock}
            </td>
        </tr>
        <tr>
            <th>现有库存</th>
            <td>
                {$res.goods_stock}
            </td>
        </tr>
        <tr>
            <th>销量</th>
            <td>
                {$res.initial_stock-$res.goods_stock}
            </td>
        </tr>
        <tr>
            <td colspan='2'>
                <select id='initial'>
                    <option value="plus">增加库存</option>
                    <option value="reduce">减少库存</option>
                </select>
                <input type="number" name="ini" id="stock" value="">
            </td>
        </tr>
        <tr>
            <td colspan='4' style='padding-left:250px;'>
                <button type="button" class="btn btn-success" onclick="but()">保&nbsp;存</button>
                <a href="{:url('admin/Goods/index')}"><span style="color: white"><button type="button" class="btn btn-primary">返&nbsp;回</button></span></a>
            </td>
        </tr>
    </table>
</form>
</body>
</html>